package com.saifan.wyy_ov.utils;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;

import com.saifan.wyy_ov.R;

/**
 * @author WangLi
 * @date 2015年3月18日 下午5:11:39
 * @Description
 * @version V1.0
 */

public class TelUtil {
	@SuppressLint("NewApi")
	public static void callPhone(final Context context, final String number) {
		if (!StringUtil.isNullOrEmpty(number)) {
			AlertDialog.Builder builder = null;
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
				 builder = new AlertDialog.Builder(context, R.style.dialog);
			}else {
				builder = new AlertDialog.Builder(context);
			}
			builder.setTitle("拨号");

			builder.setMessage("您确定要拨打电话：" + number);

			builder.setIcon(R.drawable.call);

			builder.setNegativeButton("确定", new DialogInterface.OnClickListener() {
				Intent intent;

				@Override
				public void onClick(DialogInterface dialog, int which) {
					intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
					context.startActivity(intent);
				}
			});

			builder.setPositiveButton("取消", new DialogInterface.OnClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which) {

				}
			});

			builder.create().show();
		}
	}
}
